/**
 * 资料
 * 校验规则
 */
const { query, checkSchema } = require("express-validator");

const newsValidation = {
  // 列表
  list_validation: [query("page").default(1).toInt().isInt({ min: 1 }).withMessage("请输入页码"), query("limit").default(10).toInt().isInt({ min: 1 }).withMessage("请输入每页数量")],
  // 添加
  add_validation: checkSchema({
    file_name: {
      in: ["body"],
      notEmpty: true,
      trim: true,
      errorMessage: "请输入资料名称",
    },
    file_size: {
      in: ["body"],
      notEmpty: true,
      trim: true,
      errorMessage: "请输入资料大小",
    },
    file_url: {
      in: ["body"],
      notEmpty: true,
      trim: true,
      errorMessage: "请输入资料路径",
    }
  }),
  // 修改
  update_validation: checkSchema({
    file_id: {
      in: ["body"],
      notEmpty: true,
      trim: true,
      errorMessage: "请输入资料ID",
    },
    file_name: {
      in: ["body"],
      notEmpty: true,
      trim: true,
    },
  }),
  // 删除
  delete_validation: checkSchema({
    file_id: {
      notEmpty: true,
      trim: true,
      errorMessage: "请输入资料ID",
    },
  }),
};

module.exports = newsValidation;
